#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int f(int x, int y)
{
	if (x == 1)
	{
		return 1;
	}
	int ret = 1;
	for (int i = 0; i < x; i++)
	{
		ret *= y;
	}
	return ret;
}


int main()
{
	int k, n, s = 0, i;
	scanf("%d %d", &k, &n);
	for (i = 1; i <= n; i++)
	{
		s = s + f(i, k);
	}
	printf("%d\n", s);
	return 0;
}